package org.elanfox.intellicommunity.intellicommunityadmin.mq;

import org.elanfox.intellicommunity.msg.constant.MsgConstant;
import org.elanfox.intellicommunity.msg.dto.CmdDTO;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author allan
 * @version 1.0.0
 * @date 2020/3/18
 */
@Component
public class MsgProvider {
    @Autowired
    private RabbitTemplate template;
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    /**
     * 命令发送
     *
     * @param cmdDTO
     */
    public void sendCommandMsg(CmdDTO cmdDTO) {
        Map<String, Object> msgMap = new HashMap<>();
        msgMap.put("msg", cmdDTO);
        template.convertAndSend(MsgConstant.EXCHANGE_MESSAGE, MsgConstant.QUEUE_COMMAND_REQ, msgMap);
    }
}
